package com.qf.config;

import com.qf.constatns.RabbitMQConstatns;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

    // 只要要使用Topic模型
    @Bean
    public TopicExchange sendMessageExchange() {
        return new TopicExchange(RabbitMQConstatns.SEND_MESSAGE_EXCHANGE, true, false);
    }

    @Bean
    public Queue smsQueue() {
        return new Queue(RabbitMQConstatns.SMS_QUQUE, true, false, false);
    }

    @Bean
    public Binding smsQueueBindSendMessageExchange() {
        return BindingBuilder.bind(smsQueue()).to(sendMessageExchange()).with("send.sms.*");
    }

}
